#! /usr/bin/python
#coding: utf-8

class ProjectionOfPrepositionalFramesDicEntry:
    #self.nb???
    def __init__(self, prep,sr1,sr2,grc,rel,ex):
        self.prep = prep
        self.sr1 = sr1
        self.sr2 = sr2
        self.grc = grc
        self.rel = rel
        self.ex = ex

class ProjectionOfPrepositionalFramesDic:
	"""
		 ProjectionOfVerbalPrepositionalFramesDic represents projection of VPF on the input text T:

	 """
	def __init__(self, rc, ldb):
		self._rc = rc
		#self._lsd = lsd
		self._dpf = ldb.get_dpf()
		self._build()

	def _build(self):
		self._arfrp = []
		fnoun = snoun = None
		find = 0
		for r in range(self._rc.get_rows_num()):
			#можно добавить проверку на предлог
			find = 0
			rc_r = self._rc.get_row(r)
			if 2 in rc_r.tclass and 3 not in rc_r.tclass:
				if fnoun is None:
					fnoun = r
				elif snoun is None:
					snoun = r
					find = 1
				else:
					fnoun = snoun
					snoun = r
					find = 1

			if (rc_r.unit[0] in u'., ?/][{}' or 4 not in rc_r.tclass) and not find:
				continue
			frames = []
			if find:
				frames = self._dpf.get_frames()
			else:
				self._dpf.get_frames_by_prep(rc_r.unit)
			#print frames
			for s in frames:
				self._arfrp.append(ProjectionOfPrepositionalFramesDicEntry(s[1],s[2],s[3],s[4],s[5],s[6]))

	def get_array(self):
		return self._arfrp
